//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        while(in.hasNextInt()) {
            int n = in.nextInt();
            int m = in.nextInt();
            int[][] arr = new int[n][m];
            Scanner sin = new Scanner(System.in);
            for(int i=0;i<n;i++){

                String s = sin.nextLine();
                for(int j=0;j<m;j++){
                    arr[i][j] = s.charAt(j)-'0';
                }
            }
            int ans = 0;
            for(int i=1;i<n;i++){
                for(int j=1;j<m;j++){
                    int temp_sum = 0;
                    temp_sum += arr[i-1][j-1];
                    temp_sum += arr[i-1][j];
                    temp_sum += arr[i][j-1];
                    temp_sum += arr[i][j];
                    if(temp_sum == 2)  ans++;
                }
            }
            System.out.println(ans);

        }

        //TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
        // to see how IntelliJ IDEA suggests fixing it.

    }
}